import React from 'react';
import { hashHistory } from 'react-router';
import loginVerify from 'utils/loginVerify';
const calcMoney = (price) => {
  let mixed = price % 100;
  const int = (price - mixed) / 100;
  mixed = (`0${mixed}`).slice(-2);
  // return [int, mixed];
	return int + '.' +mixed;
};

const userInfo = loginVerify.getUserDataInfo();
const isAuditAdmin = userInfo.userRoles.some((value) => {
        return value.role.name == '信审管理员';
      });
const isAudit = userInfo.userRoles.some((value) => {
        return value.role.name == '信审员';
      });
const mixId = userInfo.mixId;
module.exports = [
  {
    key:'userId',
    title:'',
    dataType:'varchar',
    // primary : true,
    width: 0,
    className: 'disnon-table',
    render: () => {
    }
  },
  {
    key:'orderId',
    title:'订单号',
    dataType:'varchar',
    render: (text) => {
      const handleClick = () => {
        const url = `/cms/manage/information/detail?orderId=${text}&status=1`;
        hashHistory.push(url);
      }
      return (<span
          onClick={handleClick}
          style={{color: '#108DE9', cursor: 'pointer'}}
        >{text}</span>)
    },
    primary : true
  },{
    key:'customerName',
    title:'姓名',
    dataType:'varchar',
  },{
    key:'phone',
    title:'手机',
    dataType:'varchar',
  },
  {
    key:'loanAmt',
    title:'借款金额',
    dataType:'varchar',
    render: (text, row, index) => {
      if(!text)
      return;
        return <span>{calcMoney(text)}元</span>;
    }
  },{
    key:'borrowType',
    title:'类别',
    dataType:'varchar',
    render: (text, row, index) => {
      if(!text)
      return;
      let showText = '';
        switch (text) {
          case 1:
            showText = '单期贷';
            break;
          case 2:
            showText = '闪电贷';
            break;
          case 3:
            showText = '分期贷';
            break;
          default:
            break;
        }
        return <span>{showText}</span>;
    }
  },{
    key:'loadDay',
    title:'借款期限',
    dataType:'varchar',
  },
  {
    key:'applyTime',
    title:'订单添加日期',
    dataType:'varchar',
    render: (text, row, index) => {
      return new Date(text).format("yyyy-MM-dd HH:mm:ss");
    }
  },{
    key:'inProcess',
    title:'所在流程',
    dataType:'varchar',
    render: (text, row, index) => {
      if(!text)
      return;
      let showText = '';
        switch (text) {
          case 1:
          case 2:
            showText = '未分配';
            break;
          case 3:
          case 4:
          case 5:
            showText = '初审';
            break;
          case 6:
            showText = '终审';
            break;
          case 7:
            showText = '结案';
            break;
          default:
            break;
        }
        return <span>{showText}</span>;
    }
  },
  {
    key:'loanChannel',
    title:'渠道',
    dataType:'varchar',
  },
  {
    key:'isNewOldSign',
    title:'新旧户',
    dataType:'varchar',
    render: (text, row, index) => {
      if(!text)
      return;
      let showText = '';
        switch (text) {
          case '1':
            showText = '新户';
            break;
          case '2':
            showText = '旧户';
            break;
          case '3':
            showText = '次户';
            break;
          default:
            break;
        }
        return <span>{showText}</span>;
    }
  },
];